# -*- coding: UTF-8 -*-
import proxy_and_image as pro
import recognize as re
from naoqi import ALProxy
import vision_definitions
import math
import cv2
import numpy as np


def test():
    resolution = vision_definitions.kVGA
    colorSpace = vision_definitions.kBGRColorSpace
    fps = 5
    # frameHeight = 0
    # frameWidth = 0
    # frameChannels = 0
    # frameArray = None
    # cameraPitchRange = 47.64/180*math.pi
    # cameraYawRange = 60.97/180*math.pi

    ip = "192.168.1.24"

    vd_proxy = pro.get_Proxy("ALVideoDevice", ip)
    videoClient = vd_proxy.subscribe("python_client", resolution, colorSpace, fps)
    n = 0
    while n < 5:
        n = n + 1
        img = pro.get_image_from_camera(0, vd_proxy, videoClient)
        # img = img.reshape(512,450,4)

        print (img.shape)
        a = re.recognize(img)

        # cv2.imshow("res", img)

        cv2.waitKey(1)
        if (a == True):
            break

        if (n == 99):
            a = False
    return a

if __name__ == '__main__':
    a = test()
    print(a)


